<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jstl/core"
                xmlns:sf="http://www.springframework.org/tags/faces"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:spring="http://www.springframework.org/tags"
                template="../../../layout/Template.xhtml">


    <ui:define name="menu">
        <ui:include src="${user.menu}"/>
    </ui:define>

    <ui:define name="title">
        <h:outputText value="#{resourceBundle.createLessonWelcome}"/>
    </ui:define>

    <ui:define name="content">
        <ui:fragment id="createLessonFragment">
            <rich:panel id="createLessonPanel"
                        header="#{resourceBundle.createLessonWelcome}">
                <h:form id="uploadLessonForm">
                    <h:panelGrid columns="2" columnClasses="uploadItem, uploadItem"
                                 styleClass="uploadGroup">

                        <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}" id="upload"
                                         immediateUpload="#{fileUploadBean.autoUpload}"
                                         allowFlash="#{fileUploadBean.useFlash}"
                                         acceptedTypes="pdf">
                            <a4j:support event="onuploadcomplete" reRender="info"/>
                        </rich:fileUpload>

                        <h:panelGroup id="info">
                            <rich:panel bodyClass="info">
                                <f:facet name="header">
                                    <h:outputText
                                            value="#{resourceBundle.createLessonUploadedFilesInfo}"/>
                                </f:facet>
                                <h:outputText
                                        value="#{resourceBundle.createLessonNoFilesCurrentlyUploaded}"
                                        rendered="#{fileUploadBean.size == 0}"/>
                                <rich:dataGrid columns="1"
                                               value="#{fileUploadBean.fileUploadeds}" var="file"
                                               rowKeyVar="row">
                                    <rich:panel>
                                        <h:panelGrid columns="2">
                                            <h:outputText
                                                    value="#{resourceBundle.createLessonFileName}:"/>
                                            <h:outputText value="#{file.name}"/>
                                            <h:outputText
                                                    value="#{resourceBundle.createLessonFileLength}:"/>
                                            <h:outputText value="#{file.length}"/>
                                        </h:panelGrid>
                                    </rich:panel>
                                </rich:dataGrid>
                            </rich:panel>
                            <rich:spacer height="3"/>
                            <br/>
                            <a4j:commandButton action="#{fileUploadBean.clearUploadData}"
                                               reRender="info, upload"
                                               value="#{resourceBundle.createLessonClearUploadedData}"
                                               rendered="#{fileUploadBean.size > 0}"/>
                        </h:panelGroup>
                    </h:panelGrid>
                </h:form>
                <h:form>
                    <a4j:commandButton type="submit" value="#{bundle.addButton}"
                                       action="add"/>
                    <a4j:commandButton value="#{bundle.cancelButton}" action="cancel"
                                       immediate="true"/>
                </h:form>
            </rich:panel>
        </ui:fragment>
    </ui:define>

</ui:composition>